<?php

// Init owncloud

require_once(OC_App::getAppPath('resumes') . "/lib/tag.php");

OCP\JSON::checkLoggedIn();

$searchTag = JRequest::getString('q', null);

$model = new PResumesModelTag();
// give max 8 items
$resumeTags = $model->getSearchTags($searchTag, 8);

$list = array();

if(!empty($resumeTags)) {
   foreach($resumeTags as $resumeTag){
      $list[] = $resumeTag->name;
   }
}

OCP\JSON::success(array('tags' => $list));